function findAllAnswer(qid){
	var arg = arguments;
	var params={
			"qid":qid	
	};
	console.log(qid);
	//sessionStorage.ques=qid;
	$.ajax({
        "contentType": "application/json; charset=utf-8",
        "type": "POST",
        "url": "allAnswer",
        "data": JSON.stringify(params),   
        "success": function (data,textStatus){
            //console.log(data);
            sessionStorage.ques=qid;
            //console.log("abc"+arg[0]);
            $("#localQustion").text("当前选择的问题：问题"+sessionStorage.ques);
            $("#answer").empty();
            for(var i in data){
        		var p=$("<p></p>");
        		var p2=$("<p></p>");
        	    //let qid=data[i].qid;
        		var aid=data[i].aid
        		var uid=data[i].uid;
        		var atime=data[i].atime;
        		var content=data[i].content;
        		p.text(aid+"回复人：用户"+uid+" "+"回复时间: "+timestampToTime(atime));
        		p2.text("内容："+content)
        		$("#answer").append(p);
        		$("#answer").append(p2); 
            } 
        }
    });
}
function addOneAnswer(){
	var params={
			"qid":sessionStorage.ques,
			"uid":sessionStorage.myUid,
			"content":$("#contentArea").val()
	};
	if(sessionStorage.ques<1){
		alert("请选择一个问题再回复");
	}else{
	if(($("#contentArea").val()).length>100||($("#contentArea").val()).length==0){
		alert("回复内容不能为空且不能超过100个字符")
	}else{
	$.ajax({
        "contentType": "application/json; charset=utf-8",
        "type": "POST",
        "url": "oneAnswer",
        "data": JSON.stringify(params),   
        "success": function (data,textStatus) {
            console.log(data);
            if(data){
            	alert("添加成功");
            }else{
            	alert("添加失败");
            }
            
        }
    });
	}}
}
function deleteOneAnswer(){
	var params={
			"aid":$("#aidArea").val()
	};
	var r = /^\+?[1-9][0-9]*$/;
	if(!r.test($("#aidArea").val())){
		alert("请输入一个正整数")
	}else{
	$.ajax({
        "contentType": "application/json; charset=utf-8",
        "type": "DELETE",
        "url": "oneAnswer",
        "data": JSON.stringify(params),   
        "success": function (data,textStatus) {
            console.log(data);
            if(data){
            	alert("删除成功");
            }else{
            	alert("删除失败");
            }
            
        }
    });
	}
}
function updateOneAnswer(){
	var params={
			"aid":$("#aidArea").val(),
			"content":$("#contentArea").val()
	};
	var r = /^\+?[1-9][0-9]*$/;
	if(!r.test($("#aidArea").val())){
		alert("请输入一个正整数")
	}else{
	if($("#contentArea").val().length>100||$("#contentArea").val().length==0){
		alert("回复内容不能为空且不能超过100个字符")
	}else{
	$.ajax({
        "contentType": "application/json; charset=utf-8",
        "type": "PUT",
        "url": "oneAnswer",
        "data": JSON.stringify(params),   
        "success": function (data,textStatus) {
            console.log(data);
            if(data){
            	alert("更新成功");
            }else{
            	alert("更新失败");
            } 
        }
    });
	}}
}